package org.example.test;

import org.example.entity.User;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class test02 {
    public static void main(String[] args) {
       /*

            这种配置的写法，就是找无参数构造方法，造bean
            <bean id="user" class="org.example.entity.User"/> new User() --- id="user"
            User user = new User();

            这种配置的写法，就是通过指定的静态工厂，为我们造bean
            <bean id="user" class="org.example.factory.UserStaticFactory" factory-method="getUser"/>  new User() id="user"
            User user = UserStaticFactory.getUser();

            这种配置的写法，就是通过指定的非静态工厂，为我们造bean
            <bean id="userFactory" class="org.example.factory.UserFactory"/>
            UserFactory userFactory = new UserFactory();

            <bean id="user" factory-bean="userFactory" factory-method="getUser"/>
            User user = userFactory.getUser();

         */
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring-context.xml");
        User user = (User) context.getBean("user");
        System.out.println(user);
    }
}
